//
//  ShowViewController.m
//  CycleAlertView-demo
//
//  Created by 苹果笔记本 on 2020/5/18.
//  Copyright © 2020 苹果笔记本. All rights reserved.
//

#import "ShowViewController.h"
#import "CycleAlertManager.h"
@interface ShowViewController ()

@end

@implementation ShowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view from its nib.
}


//从底部弹出
- (void)showFromBottom {
    
    //视图frame
    CGFloat alertW = [UIScreen mainScreen].bounds.size.width;
    CGFloat alertH = 300;
    CGFloat alertX = 0;
    CGFloat alertY = [UIScreen mainScreen].bounds.size.height - alertH;
    self.manager.presentedFrame = CGRectMake(alertX, alertY, alertW, alertH);
    //设置弹出视图背景颜色
    self.manager.coverViewBgColor = [UIColor blackColor];
    self.manager.coverViewAlpha = 0.3;
    //设置动画弹出方向
    self.manager.AlertDirection = CycleAlertViewDirectionTypeBottom;
    //设置退出弹窗消失的时间
//    self.manager.dismissTime = 0.5;
    //是否可以点击背景(有些要求点击背景或弹窗上的按钮退出/有些只希望点击弹窗上的按钮退出,default is YES)
    self.manager.canClickBgView = NO;
    //设置某个方向上的角为小圆角
    [self.manager cycle_cornerByRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadius:6];
    
    //弹出
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self animated:YES completion:nil];
    
    
    
}
//从中间弹出
- (void)showFromCenter {
    
    //屏幕尺寸比例
    double scale = [UIScreen mainScreen].bounds.size.width / 375.0;
    //视图frame
    CGFloat alertH = 300*scale;
    CGFloat alertW = alertH;
    CGFloat alertX = ([UIScreen mainScreen].bounds.size.width - alertW)*0.5;
    CGFloat alertY = ([UIScreen mainScreen].bounds.size.height - alertH)*0.5;
    self.manager.presentedFrame = CGRectMake(alertX, alertY, alertW, alertH);
    //设置弹出视图背景颜色
    self.manager.coverViewBgColor = [UIColor blackColor];
    self.manager.coverViewAlpha = 0.3;
    //设置动画弹出方向
    self.manager.AlertDirection = CycleAlertViewDirectionTypeCenter;
    //设置退出弹窗消失的时间
//    self.manager.dismissTime = 0.5;
    //是否可以点击背景(有些要求点击背景或弹窗上的按钮退出/有些只希望点击弹窗上的按钮退出,default is YES)
    self.manager.canClickBgView = YES;
    //设置弹出视图小圆角
    self.manager.cornerRadius = 6;
    
    //弹出
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self animated:YES completion:nil];
    
    
    
}


///退出
- (IBAction)exitClick:(UIButton *)sender {
    //当初始化弹出视图的时候如果设置了self.manager.canClickBgView = NO;需要恢复点击
    self.manager.canClickBgView = YES;
    //退出
    [self.manager.presentationViewController dismiss];
}

@end
